package j2024.j202409;

import java.util.Arrays;
import java.util.Scanner;

public class j0928 {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        System.out.println(Sort(arr));;
    }
    public static int Sort(int[] arr){
        int index = 1;
        int ret = 0;
        if(arr.length==1){
            return 1;
        }
        boolean tmp=false;
        while(index<arr.length){
            while (index<arr.length && arr[index]>arr[index-1]){
                index++;
                tmp = true;
            }
            if(tmp){
                ret++;
                index++;
                tmp = false;
            }
            while(index<arr.length && arr[index]==arr[index-1]){
                index++;
            }
            while (index<arr.length && arr[index]<arr[index-1]){
                index++;
                tmp = true;
            }
            if(tmp){
                ret++;
                index++;
                tmp = false;
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        for (int i = 0; i < n; i++) {
            System.out.println(rett(arr[i]));
        }
    }
    public static int rett(int a){
        int ret = 0;
        int jian = 1;
        while(a!=0){
            a-=jian;
            ret++;
            if(a%(jian*2)==0){
                jian*=2;
            }
        }
        return ret;
    }
    public int LIS (int[] a) {
        // write code here
        int n = a.length;
        int[] dp = new int[n+1];
        int index = 0;
        for (int i = 0; i < n; i++) {
            if(index==0 || a[i]>dp[index]){
                dp[++index] = a[i];
            }else {
                int left = 1,right = index;
                while(left<right){
                    int mid = (left+right)/2;
                    if(dp[mid]>=a[i]){
                        right = mid;
                    }else {
                        left = mid+1;
                    }
                }
                dp[left] = a[i];
            }
        }
        return index;
    }

    /**
     * 73. 矩阵置零
     * 给定一个 m x n 的矩阵，如果一个元素为 0 ，则将其所在行和列的所有元素都设为 0 。
     * 请使用 原地 算法。
     * @param matrix
     */
    public void setZeroes(int[][] matrix) {
        int m = matrix.length,n = matrix[0].length;
        boolean r0 = false,c0 = false;
        for(int i = 0;i < m;i++){
            if(matrix[i][0] == 0){
                r0 = true;
                break;
            }
        }
        for(int i = 0;i < n;i++){
            if(matrix[0][i] == 0){
                c0 = true;
                break;
            }
        }
        for(int i = 1;i<m;i++){
            for(int j = 1;j<n;j++){
                if(matrix[i][j]==0){
                    matrix[0][j] = matrix[i][0] = 0;
                }
            }
        }
        for(int j = 1;j<n;j++){
            if(matrix[0][j]==0){
                for(int i = 1;i<m;i++){
                    matrix[i][j] = 0;
                }
            }
        }
        for(int i = 1;i<m;i++){
            if(matrix[i][0]==0){
                Arrays.fill(matrix[i],0);
            }
        }
        if(r0){
            for(int i = 0;i<m;i++){
                matrix[i][0] = 0;
            }
        }
        if(c0){
            Arrays.fill(matrix[0],0);
        }
    }
}
